<?php
@require_once("bin/data.php");
@session_start();

$user = getUser(@$_SESSION['userid']);

$userid = $user['id'];

$title = "Channels";
$header = "";
$link = "";
$footer="";
$content = <<<EOF
<div id="channel_categories">
EOF;

$sql = "SELECT * FROM `$tblcategory` order by title ASC;";
$result = @mysql_query($sql);
while($row=@mysql_fetch_array($result))
{
	$subcontent = <<<EOF
	
	<div id="channel_entry">
	<a href="channel.php?channel={$row['id']}">
	<img id="channel_image" style="background:url(images/categories/{$row['id']}.jpg);" src="images/categories/overlay.png" alt="{$row['title']}" />
	<div id="channel_title">{$row['title']}</div>
	</a>
	</div>
	
EOF;
	$content= $content.$subcontent;
}

$content = $content."</div>";

if (isset($_REQUEST['view']))
{
	$sql = "SELECT * FROM `$tblrecords` where id = ".$_REQUEST['view'];
	$result = @mysql_query($sql);
	$row=@mysql_fetch_row($result);
	$content = <<<EOF
	

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

	<script type="text/javascript">
	function getPlayer()
	{
		if (navigator.appName.indexOf("Microsoft") != -1)
		{
			return window['glideplayer'];
		}
		else
		{
			return document['glideplayer'];
		}
     	}
	</script>

	    

    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>

<!-- Place this tag after the last +1 button tag. -->
<script type="text/javascript">
  (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();
</script>

	<div id="glide_title">{$row[2]}</div>
	<table border="0">
	<tr>
	<td valign="top" width="100px">	
		<div class="fb-like" data-href="http://www.glidecast.com" data-send="false" data-layout="button_count" data-show-faces="true" data-font="arial"></div>
	</td>
	<td valign="top" width="100px">	
		<a href="https://twitter.com/share" class="twitter-share-button" data-lang="en">Tweet</a>
	</td>
	<td valign="top" width="100px">	
		<!-- Place this tag where you want the +1 button to render. -->
		<div class="g-plusone" data-size="medium"></div>
	</td>
	
	</tr>
	</table>
	<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" 

	codebase="http://download.macromedia.com/pub/shockwave/
	cabs/flash/swflash.cab#version=6,0,40,0" 
	 
	width="640" height="385" 
	 id="glideplayer"> 

	<param name="movie"  

	value="player/GlidePlayer.swf?_gcid={$_REQUEST['view']}" /> 
	 
	<param name="quality" value="high" /> 

	<param name="bgcolor" value="#ffffff" /> 
	<param name="allowFullScreen" value="true" />
	<param name="allowScriptAccess" value="always" />

	<embed src="player/GlidePlayer.swf?_gcid={$_REQUEST['view']}" quality="high" bgcolor="#ffffff"

	width="640" height="385" 

	name="glideplayer" align="" type="application/x-shockwave-flash" 

	pluginspage="http://www.macromedia.com/go/getflashplayer" allowFullScreen="true" allowScriptAccess="always"> 


	</embed> 

	</object> 
	<div id="glide_description">{$row[3]}</div>
	<br />
	
	<div class="fb-comments" data-href="http://glidecast.com" data-num-posts="2" data-width="640"></div>
EOF;
}
else if (isset($_REQUEST['channel']))
{
$content = <<<EOF
<div id="channel_categories">
EOF;

	$channel = null;

	if (isset($_REQUEST['channel']))
	{
		$channel = mysql_real_escape_string($_REQUEST['channel']);
		unset($_SESSION["channel"]); 
		$_SESSION["channel"] = $channel;
	}

$subcontent = getFormattedRecordList(@$_SESSION['query'], @$_SESSION["channel"], $userid);
$content= $content.$subcontent;

$content = $content."</div>";
}



include ("base.php");
echo $html;
?>
